package dao;

import java.util.ArrayList;
import java.util.List;

import entity.ShopCar;

public class ShopCarDao extends BaseDao {

	/**
	 * 根据商品id查询  购物车信息
	 * @param commodityId
	 * @return
	 */
	public List<ShopCar> selectShop(int commodityId){
		try {
			rs=executeQuery("SELECT commodity.shopName,commodity.commodityPicture,commodity.commodityTitle,commodity.price,shopcar.nums from shopcar,commodity WHERE commodity.commodityId=?", commodityId);
			List<ShopCar> shopCarList=new ArrayList<ShopCar>();
			while(rs.next()) {
				ShopCar shop=new ShopCar();
				shop.setShopName(rs.getString("shopName"));
				shop.setCommodityPicture(rs.getString("commodityPicture"));
				shop.setCommodityTitle(rs.getString("commodityTitle"));
				shop.setPrive(rs.getDouble("price"));
				shop.setNums(rs.getInt("nums"));
				shopCarList.add(shop);
			}
			return shopCarList;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
		
	}
}
